import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/screenutil_init.dart';
import 'package:provider/provider.dart';
import './router/router.dart';
import './provider/SystemInfo.dart';
import './utils/utils.dart';

void main() {
  runApp(MyApp());
  if (Platform.isAndroid) {
    //设置Android头部的导航栏透明
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatefulWidget {
  MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      // 设置系统默认字体颜色为dark
      value: SystemUiOverlayStyle.dark,
      child: MultiProvider(
          providers: [ChangeNotifierProvider.value(value: SystemInfo())],
          child: ScreenUtilInit(
              designSize: Size(750, 1334),
              allowFontScaling: false,
              child: MaterialApp(
                  navigatorKey: Utils.navigatorKey,
                  theme: ThemeData(
                    // brightness: Brightness.dark,
                    primaryColor: Color(0xff163f3b),
                    accentColor: Colors.white,
                  ),
                  debugShowCheckedModeBanner: false,
                  initialRoute: '/',
                  onGenerateRoute: onGenerateRoute))),
    );
  }
}
